﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Zj.CourseManage.Domain.Core
{
    /// <summary>
    /// 课程
    /// </summary>
    public class Course
    {
        public Course()
        {
            this.Enrollments = new HashSet<Enrollment>();
            this.Title = string.Empty;
            this.Credits = 1;
            this.CourseAssignments = new HashSet<CourseAssignment>();
        }
        [Key]
        public int Id { get; set; }

        [Required(ErrorMessage ="课程标题必填")]
        [StringLength(30,MinimumLength =2,ErrorMessage ="课程标题最少两个字符，不超过30个字符")]
        public string Title { get; set; }

        [DisplayFormat(NullDisplayText ="暂无成绩")]
        [Range(0,100)]
        public int Credits { get; set; }


        public virtual ICollection<Enrollment> Enrollments { get; set; }



        public virtual ICollection<CourseAssignment> CourseAssignments { get; set; }

    }
}
